package com.example.book

import com.example.book.repository.BookDao
import com.example.book.repository.BookWebService
import com.example.demo.DemoDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class BookModule {

    @Provides
    fun bookDao(demoDatabase: DemoDatabase): BookDao {
        return demoDatabase.bookDao()
    }

    @Provides
    @Singleton
    fun bookWebService(retrofit: Retrofit): BookWebService = retrofit.create(BookWebService::class.java)
}